package com;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.common.utils.*;
import com.entity.*;
import com.service.CodeCjlService;
import com.service.SharesDetailService;
import com.service.SharesGdChangeService;
import com.service.SharesReviewService;
import org.apache.hc.client5.http.classic.methods.HttpGet;
import org.apache.hc.client5.http.impl.classic.CloseableHttpResponse;
import org.apache.hc.core5.http.io.entity.EntityUtils;
import org.apache.poi.xssf.usermodel.XSSFRow;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.CollectionUtils;

import java.io.*;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

@SpringBootTest
@RunWith(SpringRunner.class)
public class SharesReviewDemo {

    @Autowired
    private SharesReviewService sharesReviewService ;

    @Autowired
    private SharesGdChangeService sharesGdChangeService;

    @Autowired
    private SharesDetailService sharesDetailService;

    @Autowired
    private CodeCjlService codeCjlService;

    public  static  int intIndex=1;


    /**
     * 去重
     */
    @Test
    public void getdis(){
        Wrapper<SharesReview> wr=new EntityWrapper<>();
        List<SharesReview> reviewList = sharesReviewService.selectList(wr);
        List<SharesReview> delList =new ArrayList<>();
        Map<String,SharesReview> disMap=new HashMap<>();
        for (SharesReview sharesReview : reviewList) {
            String code = sharesReview.getCode();
            String time = sharesReview.getTime();
            SharesReview vo = disMap.get(code + time);
            if(vo!=null){
                delList.add(sharesReview);
            }else{
                disMap.put(code + time,sharesReview);
            }
        }

        if(!CollectionUtils.isEmpty(delList)){
            for (SharesReview sharesReview : delList) {
                sharesReviewService.deleteById(sharesReview.getId());
            }
        }
    }

    @Test
    public void getre(){

        Wrapper<SharesDetail> wr=new EntityWrapper<>();
        List<SharesDetail> sharesDetails = sharesDetailService.selectList(wr);

        Map<String,SharesDetail> smap=new HashMap<>();
        for (SharesDetail sharesDetail : sharesDetails) {
            String code = sharesDetail.getCode();
            smap.put(code,sharesDetail);

        }


        String url="http://124.220.197.73:9200/shares/getHiCode";
            try {
                HttpGet get=new HttpGet(url);
                CloseableHttpResponse execute = HttpClient5Utils.httpclient.execute(get);
                String result = EntityUtils.toString(execute.getEntity(), "UTF-8");
                JSONObject datas2 = JSONObject.parseObject(result);
                String data = datas2.getString("data");
                List<HintShares> hintSharesList = JSONArray.parseArray(data, HintShares.class);
                List<SharesReview> reviewList=new ArrayList<>();
                for (HintShares hintShares : hintSharesList) {

                    String newZdf = hintShares.getNewZdf();
                    if(hintShares.getTsOrder()>20){
                        if(StringUtil.isEmpty(newZdf)||new BigDecimal(newZdf).compareTo(new BigDecimal(10))==-1){
                            continue;
                        }
                    }

                    SharesReview sharesReview = new SharesReview();
                    sharesReview.setCode(hintShares.getCode());

                    int order = hintShares.getTsOrder();
                    sharesReview.setOrder(order);
                    sharesReview.setName(hintShares.getName());
                    sharesReview.setCode(hintShares.getCode());
                    if(null!=hintShares.getTsprice()){
                        sharesReview.setTsprice(hintShares.getTsprice().toString());
                    }
                    sharesReview.setTime(hintShares.getTime());
                    sharesReview.setZhint(hintShares.getZhint());
                    sharesReview.setYhint(hintShares.getYhint());
                    sharesReview.setType(hintShares.getType());
                    sharesReview.setSgin(hintShares.getSgin());
                    sharesReview.setKeepNum(hintShares.getKeepNum());
                    sharesReview.setKeepTotal(hintShares.getKeepTotal());
                    if(null!=hintShares.getCPrice()){
                        sharesReview.setCprice(hintShares.getCPrice().toString());
                    }
                    sharesReview.setTsZdf(hintShares.getTsZdf());
                    if(null!=hintShares.getNewPrice()){
                        sharesReview.setNewPrice(hintShares.getNewPrice().toString());
                    }
                    try {
                        sharesReview.setSrcf(MeUtils.imgBase64(hintShares.getSrcf()));
                        sharesReview.setSrc5(MeUtils.imgBase64(hintShares.getSrc5()));
                        sharesReview.setSrcr(MeUtils.imgBase64(hintShares.getSrcr()));
                        sharesReview.setSrcz(MeUtils.imgBase64(hintShares.getSrcz()));
                        sharesReview.setSrcy(MeUtils.imgBase64(hintShares.getSrcy()));
                    }catch (Exception e){
                        System.out.println("图片转换err");
                    }


                    sharesReview.setZyPrice(hintShares.getZyPrice());
                    sharesReview.setZback(hintShares.getZback());
                    sharesReview.setYback(hintShares.getYback());
                    sharesReview.setUnfastenDay(hintShares.getUnfastenDay());
                    if(!CollectionUtils.isEmpty(hintShares.getUnfastenList())){
                        sharesReview.setUnfastenList(JSONObject.toJSONString(hintShares.getUnfastenList()));
                    }
                    sharesReview.setSshy(hintShares.getSshy());
                    sharesReview.setNewZdf(hintShares.getNewZdf());
                    sharesReview.setZzfsign(hintShares.getZzfsign());
                    sharesReview.setZzdfsub(hintShares.getZzdfsub());
                    sharesReview.setMaxzzdf(hintShares.getMaxzzdf());
                    sharesReview.setYzdfsub(hintShares.getYzdfsub());
                    sharesReview.setMaxyzdf(hintShares.getMaxyzdf());
                    if(!CollectionUtils.isEmpty(hintShares.getZvoList())){
                        sharesReview.setZvoList(JSONObject.toJSONString(hintShares.getZvoList()));
                    }
                    sharesReview.setYzfsign(hintShares.getYzfsign());
                    if(!CollectionUtils.isEmpty(hintShares.getSharesHyzxes())){
                        sharesReview.setSharesHyzxes(JSONObject.toJSONString(hintShares.getSharesHyzxes()));
                    }
                    if(!CollectionUtils.isEmpty(hintShares.getNotices())){
                        sharesReview.setNotices(JSONObject.toJSONString(hintShares.getNotices()));
                    }
                    if(!CollectionUtils.isEmpty(hintShares.getSharesDirections())){
                        sharesReview.setSharesDirections(JSONObject.toJSONString(hintShares.getSharesDirections()));
                    }
                    if(!CollectionUtils.isEmpty(hintShares.getYvoList())){
                        sharesReview.setYvoList(JSONObject.toJSONString(hintShares.getYvoList()));
                    }
                    if(!CollectionUtils.isEmpty(hintShares.getSharesBgczs())){
                        sharesReview.setSharesBgczs(JSONObject.toJSONString(hintShares.getSharesBgczs()));
                    }
                    if(!CollectionUtils.isEmpty(hintShares.getSharesYjygs())){
                        sharesReview.setSharesYjygs(JSONObject.toJSONString(hintShares.getSharesYjygs()));
                    }
                    if(!CollectionUtils.isEmpty(hintShares.getSharesYjbgs())){
                        sharesReview.setSharesYjbgs(JSONObject.toJSONString(hintShares.getSharesYjbgs()));
                    }
                    if(!CollectionUtils.isEmpty(hintShares.getSharesGdnums())){
                        sharesReview.setSharesGdnums(JSONObject.toJSONString(hintShares.getSharesGdnums()));
                    }
                    if(!CollectionUtils.isEmpty(hintShares.getSharesGdChanges())){
                        sharesReview.setSharesGdChanges(JSONObject.toJSONString(hintShares.getSharesGdChanges()));
                    }
                    if(null!=hintShares.getBkzj()){
                        sharesReview.setBkzj(JSONObject.toJSONString(hintShares.getBkzj()));
                    }
                    if(null!=hintShares.getGgzj()){
                        sharesReview.setGgzj(JSONObject.toJSONString(hintShares.getGgzj()));
                    }
                    if(null!=hintShares.getGgsyl()){
                        sharesReview.setGgsyl(JSONObject.toJSONString(hintShares.getGgsyl()));
                    }
                    if(null!=hintShares.getHysyl()){
                        sharesReview.setHysyl(JSONObject.toJSONString(hintShares.getHysyl()));
                    }
                    sharesReview.setSshy(hintShares.getSshy());
                    sharesReview.setSshyPercent(hintShares.getSshyPercent());


//                    sharesReview.setSsgn(hintShares.getSsgn());
                    sharesReview.setSsgn(smap.get(sharesReview.getCode()).getSsgn());
                    sharesReview.setTjDate(hintShares.getTjDate());

                    reviewList.add(sharesReview);
                }
                if(!CollectionUtils.isEmpty(reviewList)){
                    List<SharesReview> collect = reviewList.stream().sorted(Comparator.comparing(SharesReview::getOrder)).collect(Collectors.toList());
                    sharesReviewService.insertBatch(collect);
                }
            }catch (Exception e){
                e.printStackTrace();
            }

    }

    @Test
    public void getsj(){
        Wrapper<SharesReview> wr=new EntityWrapper<>();
        List<SharesReview> reviewList = sharesReviewService.selectList(wr);
        List<HintShares> hintSharesList = sharesReviewService.changeHi(reviewList);
        hintSharesList.size();
    }

    /**
     * 获取股东变化市值
     */
    @Test
    public void  getgdchange(){
        Wrapper<SharesGdChange> wr=new EntityWrapper<>();
        wr.orderBy("endDate");
        wr.isNotNull("avg_hold_amt");
        List<SharesGdChange> sharesGdChanges = sharesGdChangeService.selectList(wr);
        Map<String,List<SharesGdChange>> gdMap=new HashMap<>();
        for (SharesGdChange sharesGdChange : sharesGdChanges) {
            String code = sharesGdChange.getCode();
            List<SharesGdChange> voList = gdMap.get(code);
            if(!CollectionUtils.isEmpty(voList)){
                voList.add(sharesGdChange);
            }else{
                List<SharesGdChange> toList=new ArrayList<>();
                toList.add(sharesGdChange);
                gdMap.put(code,toList);
            }
        }

        Map<String,BigDecimal> zfMap=new HashMap<>();

        List<SharesGdChange>  glList=new ArrayList<>();

        for (String key : gdMap.keySet()) {
            //计算期间涨幅
            List<SharesGdChange> voList = gdMap.get(key);
            if(!CollectionUtils.isEmpty(voList)&&voList.size()>1){
                for(int i=1;i<voList.size();i++){
                    String avgBuffer = voList.get(i).getAvgHoldAmt();
                    String avgAfter = voList.get(i - 1).getAvgHoldAmt();
                    BigDecimal zf = MeUtils.calculateTrend(avgAfter, avgBuffer);
                    zfMap.put(avgBuffer,zf);
                    BigDecimal[] sb = new BigDecimal(avgBuffer).divideAndRemainder(new BigDecimal(10000));
                    BigDecimal[] sa = new BigDecimal(avgAfter).divideAndRemainder(new BigDecimal(10000));
                    SharesGdChange sharesGdChange=new SharesGdChange();
                    sharesGdChange.setAvgFreeShares(sb[0].intValue()+"");//开始的价格
                    sharesGdChange.setAvgFreesharesRatio(sa[0].intValue()+"");//结束的价格
                    sharesGdChange.setAvgHoldAmt(zf.setScale(1,BigDecimal.ROUND_HALF_UP).toString());//期间涨幅
                    glList.add(sharesGdChange);
                }
            }
        }

        Map<String,List<SharesGdChange>> zfgl =new HashMap<>();
        for (SharesGdChange sharesGdChange : glList) {
            System.out.println(sharesGdChange.getAvgFreeShares()+"="+sharesGdChange.getAvgFreesharesRatio()+"="+sharesGdChange.getAvgHoldAmt());
            List<SharesGdChange> voList = zfgl.get(sharesGdChange.getAvgFreeShares());
            if(!CollectionUtils.isEmpty(voList)){
                voList.add(sharesGdChange);
            }else{
                List<SharesGdChange> toList=new ArrayList<>();
                toList.add(sharesGdChange   );
                zfgl.put(sharesGdChange.getAvgFreeShares(),toList);
            }
        }
        System.out.println("=======");
        //计算多少w有多少支
        for (String key : zfgl.keySet()) {
            List<SharesGdChange> voList = zfgl.get(key);
            BigDecimal avgzf=new BigDecimal("0");

            double add=0;
            double sub=0;
            for (SharesGdChange sharesGdChange : voList) {
                String avgHoldAmt = sharesGdChange.getAvgHoldAmt();
                avgzf.add(new BigDecimal(avgHoldAmt));
                if(new BigDecimal(avgHoldAmt).compareTo(new BigDecimal(0))==1){
                    add=add+1;
                }else {
                    sub=sub+1;
                }
            }
            BigDecimal divide = avgzf.divide(new BigDecimal(voList.size()), 2, BigDecimal.ROUND_HALF_UP);
            System.out.println(key+"="+voList.size()+"="+divide+"sub="+sub+"add="+add);
        }
        //计算他们的涨幅

    }

    /**
     *
     */
    @Test
    public void getl(){
        sharesReviewService.saveData();
    }

    /**
     * 股东价格变化
     */
    @Test
    public void getgdb(){
//        List<String> list=new ArrayList<>();
        Wrapper<SharesGdChange> wr=new EntityWrapper<>();
        wr.orderBy("endDate");
        wr.isNotNull("avg_hold_amt");
        wr.isNotNull("price");
        wr.gt("holder_total_num",1000);
//        wr.in("end_date",list);
        List<SharesGdChange> sharesGdChanges = sharesGdChangeService.selectList(wr);
        Map<String,List<SharesGdChange>> gdMap=new HashMap<>();
        List<SharesGdChange> votjs=new ArrayList<>();

        for (SharesGdChange sharesGdChange : sharesGdChanges) {
            String code = sharesGdChange.getCode();
            List<SharesGdChange> voList = gdMap.get(code);

            //计算此时的市值
            String avgHoldAmt = sharesGdChange.getHolderTotalNum();
            String avgFreeShares = sharesGdChange.getAvgHoldAmt();
            BigDecimal multiply = new BigDecimal(avgHoldAmt).multiply(new BigDecimal(avgFreeShares));
            sharesGdChange.setSz(multiply.setScale(2,BigDecimal.ROUND_HALF_UP)+"");

            if(!CollectionUtils.isEmpty(voList)){
                voList.add(sharesGdChange);
            }else{
                List<SharesGdChange> toList=new ArrayList<>();
                toList.add(sharesGdChange);
                gdMap.put(code,toList);
            }
        }

        List<String> list = new ArrayList<>();
        list.add("名字");
        list.add("时间");
        list.add("上次市值");
        list.add("本次市值");
        list.add("上次价格");
        list.add("本价格");
        list.add("涨幅");
        list.add("上次户市值");
        list.add("本次户市值");
        list.add("上次股东人数");
        list.add("上次股东描述");
        list.add("本次股东人数");
        list.add("本次股东描述");
        list.add("较上期变化");
        list.add("相差多少天");


        XSSFWorkbook wb = new XSSFWorkbook(); // 创建工作空间
        XSSFSheet excel = ExcelUtils.getAddExcel(wb, list, "sheeh");
        for (String key : gdMap.keySet()) {


            List<SharesGdChange> voList = gdMap.get(key);
            Map<String, CodeCjl> priceMap = getPriceList(voList.get(0));


            List<SharesGdChange> vos=new ArrayList<>();
            if(!CollectionUtils.isEmpty(voList)&&voList.size()>2){
                for (int i=2;i<voList.size();i++){
                    //计算股价期间的涨幅
                    SharesGdChange voBuffer = voList.get(i - 1);
                    SharesGdChange voAfter = voList.get(i);


                    //价格，，，
                    String timeb = voBuffer.getEndDate().substring(0, 10);
                    String timea = voAfter.getEndDate().substring(0, 10);


                    CodeCjl pa = priceMap.get(timea);

                    for (int j=1;j<10;j++){
                        if(null==pa){
                            String ymdByDaysAgo = DateUtil.getYMDByDaysAgo(timea, j);
                         //   System.out.println("a"+ymdByDaysAgo+"=="+voBuffer.getCode());
                            pa= priceMap.get(ymdByDaysAgo);
                        }
                    }

                    CodeCjl pb = priceMap.get(timeb);

                    for (int j=1;j<10;j++){
                        if(null==pb){
                            String ymdByDaysAgo = DateUtil.getYMDByDaysAgo(timeb, j);
                          //  System.out.println("b"+ymdByDaysAgo+"=="+voBuffer.getCode());
                            pb= priceMap.get(ymdByDaysAgo);
                        }
                    }

                    if(null==pb||null==pa){
                        System.out.println("null");
                        continue;
                    }


                    //价格计算=股东市值/股东人数
//                    String avgb = voBuffer.getAvgHoldAmt();
//                    String nmb = voBuffer.getHolderTotalNum();
//                    String nma = voAfter.getHolderTotalNum();
//                    String avga = voAfter.getAvgHoldAmt();
//
//                    String ap=new BigDecimal(avga).divide(new BigDecimal(nma),2,BigDecimal.ROUND_HALF_UP)+"";
//                    String bp=new BigDecimal(avgb).divide(new BigDecimal(nmb),2,BigDecimal.ROUND_HALF_UP)+"";


                    //计算两个数据相差的天数>88
                    BigDecimal zf = MeUtils.calculateTrend(pa.getZPrice().toString(), pb.getZPrice().toString());
                    voAfter.setZf(MeUtils.getPercent(zf.toString())+"%");
                    voAfter.setPrice(pa.getZPrice().toString());

//                    @TableField(exist = false)//上次的价格
//                    private String shsz;//上次的户市值
                    voAfter.setShsz(voBuffer.getAvgHoldAmt());
//                    @TableField(exist = false)//上次的价格
//                    private String gdrs;//上次的股东人数
                    voAfter.setGdrs(voBuffer.getHolderTotalNum());
//                    @TableField(exist = false)//上次的价格
                    voAfter.setSprice(pb.getZPrice().toString());
//                    private String gdrsms;//上次的股东ms
                    voAfter.setGdrsms(voBuffer.getHoldFocus());

                    String end = voAfter.getEndDate().substring(0, 10);
                    String start = voBuffer.getEndDate().substring(0, 10);
                    //相差多少天
                    try {
                        Long timeByend = DateUtil.getTimeByStr(end);
                        Long timeBystart = DateUtil.getTimeByStr(start);
                        long l = DateUtil.DaysBetweenByLong(timeBystart, timeByend);
                        voBuffer.setDays(l);
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                    vos.add(voAfter);

                }

                //输出
                for (SharesGdChange sharesGdChange : vos) {
                    votjs.add(sharesGdChange);

                    String name = sharesGdChange.getName();
                    String endDate = sharesGdChange.getEndDate();//时间
                    String sz = sharesGdChange.getSz();//市值
                    String zf = sharesGdChange.getZf();//涨幅
                    String price = sharesGdChange.getPrice();//价格
                    String avgHoldAmt = sharesGdChange.getAvgHoldAmt();//人均持股金额
                    String holderTotalNum = sharesGdChange.getHolderTotalNum();//股东人数

                    XSSFRow newRow = excel.createRow(intIndex++); // 一行
                    int indexSize=0;

                    newRow.createCell(indexSize++).setCellValue(name);
                    newRow.createCell(indexSize++).setCellValue(endDate);
                    newRow.createCell(indexSize++).setCellValue(sz);
                    newRow.createCell(indexSize++).setCellValue(new BigDecimal(sharesGdChange.getShsz()).multiply(new BigDecimal(sharesGdChange.getGdrs()))+"");
                    newRow.createCell(indexSize++).setCellValue(sharesGdChange.getSprice());
                    newRow.createCell(indexSize++).setCellValue(price);
                    newRow.createCell(indexSize++).setCellValue(zf);
                    newRow.createCell(indexSize++).setCellValue(sharesGdChange.getShsz());
                    newRow.createCell(indexSize++).setCellValue(avgHoldAmt);
                    newRow.createCell(indexSize++).setCellValue(sharesGdChange.getGdrs());
                    newRow.createCell(indexSize++).setCellValue(sharesGdChange.getGdrsms());
                    newRow.createCell(indexSize++).setCellValue(holderTotalNum);
                    newRow.createCell(indexSize++).setCellValue(sharesGdChange.getHoldFocus());
                    newRow.createCell(indexSize++).setCellValue(sharesGdChange.getTotalNumRatio());
                    newRow.createCell(indexSize++).setCellValue(sharesGdChange.getDays());
                    newRow.createCell(indexSize++).setCellValue(MeUtils.getPercent(MeUtils.calculateTrend(avgHoldAmt,sharesGdChange.getShsz())+"")+"%");
                }
            }

        }

        //统计
        List<SharesGdChange>  zfList100=new ArrayList<>();
        List<SharesGdChange>  zfList50_100=new ArrayList<>();
        List<SharesGdChange>  zfList0_50=new ArrayList<>();
        List<SharesGdChange>  zfList_0_50=new ArrayList<>();
        List<SharesGdChange>  zfList_50=new ArrayList<>();
        for (SharesGdChange votj : votjs) {
            String zf = votj.getZf().replaceAll("%","");

            if(new BigDecimal(zf).compareTo(new BigDecimal(100))==1){
                zfList100.add(votj);
            }
            if((new BigDecimal(zf).compareTo(new BigDecimal(50))==1)
                &&(new BigDecimal(zf).compareTo(new BigDecimal(100))==-1)){
                zfList50_100.add(votj);
            }
            if((new BigDecimal(zf).compareTo(new BigDecimal(0))==1)
                &&(new BigDecimal(zf).compareTo(new BigDecimal(50))==-1)){
                zfList0_50.add(votj);
            }
            if((new BigDecimal(zf).compareTo(new BigDecimal(-50))==1)
                &&(new BigDecimal(zf).compareTo(new BigDecimal(0))==-1)){
                zfList_0_50.add(votj);
            }
            if(new BigDecimal(zf).compareTo(new BigDecimal(-50))==-1){
                zfList_50.add(votj);
            }
        }

        //
        getTjList(zfList100);
        getTjList(zfList50_100);
        getTjList(zfList0_50);
        getTjList(zfList_0_50);
        getTjList(zfList_50);

        FileOutputStream out = null;
        try {
            out = new FileOutputStream("D:" + File.separator+"dc"+File.separator+
                    "股东数据"+System.currentTimeMillis() +".xls");
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        try {
            wb.write(out);
            out.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

    private void getTjList(List<SharesGdChange> zfList100) {
        int add=0;
        int sub=0;
        for (SharesGdChange sharesGdChange : zfList100) {
            String holdFocus = sharesGdChange.getHoldFocus();
            String shsz = sharesGdChange.getShsz();
            String avgHoldAmt = sharesGdChange.getAvgHoldAmt();
            if(holdFocus.contains("集中")){
                add++;
            }
            if(holdFocus.contains("分散")){
                sub++;
            }

//            if(new BigDecimal(shsz).compareTo(new BigDecimal(avgHoldAmt))==1){
//                sub++;
//            }else{
//                add++;
//            }
        }
        System.out.println("集中 = " + add+"分散 = "+sub);

    }

    private  Map<String,CodeCjl>  getPriceList(SharesGdChange sharesGdChange) {

        String szorsh = sharesGdChange.getCode();

        List<CodeCjl> codeCjls=new ArrayList<>();
        System.out.println(szorsh);
        String substring = szorsh.substring(2);
        String url="";
        if(szorsh.contains("sz")){



            url="http://push2his.eastmoney.com/api/qt/stock/kline/get" +
                    "?cb=jQuery1124002171762069302452_"  +new Date().getTime()+
                    "&fields1=f1%2Cf2%2Cf3%2Cf4%2Cf5%2Cf6&fields2=f51%2Cf52%2Cf53%2Cf54%2Cf55%2Cf56%2Cf57%2Cf58%2Cf59%2Cf60%2Cf61&ut=7eea3edcaed734bea9cbfc24409ed989&klt=101&fqt=1" +
                    "&secid=0." +substring +
                    "&beg=0&end=20500000&_="+new Date().getTime();
        }

        if(szorsh.contains("sh")){

            url="http://push2his.eastmoney.com/api/qt/stock/kline/get" +
                    "?cb=jQuery1124002171762069302452_"  +new Date().getTime()+
                    "&fields1=f1%2Cf2%2Cf3%2Cf4%2Cf5%2Cf6&fields2=f51%2Cf52%2Cf53%2Cf54%2Cf55%2Cf56%2Cf57%2Cf58%2Cf59%2Cf60%2Cf61&ut=7eea3edcaed734bea9cbfc24409ed989&klt=101&fqt=1" +
                    "&secid=1." +substring +
                    "&beg=0&end=20500000&_="+new Date().getTime();

        }

        try{
            HttpGet get=new HttpGet(url);
            CloseableHttpResponse execute = HttpClient5Utils.httpclient.execute(get);
            String result = EntityUtils.toString(execute.getEntity(), "UTF-8");
            int rIndex = result.indexOf("(");
            String resultStr = result.substring(rIndex + 1, result.length() - 2);
            JSONObject datas2 = JSONObject.parseObject(resultStr);
            String data = datas2.getString("data");
            String klines = JSONObject.parseObject(data).getString("klines");
            List<Object> parse = (List<Object>) JSON.parse(klines);
            codeCjls= codeCjlService.getPriceList(parse,szorsh,sharesGdChange.getName());

        }catch (Exception e){
            e.printStackTrace();
        }

        Map<String,CodeCjl> map=new HashMap<>();
        for (CodeCjl codeCjl : codeCjls) {
            String time = codeCjl.getTime();
            map.put(time,codeCjl);
        }

        return map;
    }




}
